package com.jingdianjichi.subject.application.mq.consumer;

import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

/**
 * 测试mq消息的接受
 */
@Component
@RocketMQMessageListener(topic = "first-topic", consumerGroup = "test-consumer")       //指定监听的话题和消费组就在注解中定义即可
@Slf4j
//实现监听器的接口,泛型是消息的类型
public class TestConsumer implements RocketMQListener<String> {

    //消费消息
    @Override
    public void onMessage(String message) {
        log.info("接受到了mq的消息:{}",message);
    }
}
